<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,initial-scale=1.0,width=device-width" />
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>店铺</title>
    <link rel="stylesheet" type="text/css" href="../../../css/aui/aui.css" />
    <link rel="stylesheet" type="text/css" href="../../../css/aui/aui-slide.css" />
    <style>
        .iconimg {
            width: 3.4rem;
            height:3.4rem;
            display: inline-block;
            border-radius: 100%;
        }

        #shopping_cart {
            position: fixed;
            z-index: 99;
            background: rgba(0, 0, 0, .6);
            width: 3rem;
            right: .4rem;
            bottom: 10rem;
            color: white;
            text-align: center;
            border-radius: .3rem;
            padding: .3rem 0;
            font-size: .7rem;
        }

        #shopping_cart img {
            width: 50%;
            margin: 0 auto;
        }

        #shop_recommended .aui-card-list-header {
            display: -webkit-box !important;
            -webkit-box-align: start;
            font-size: .75rem;
            margin-top: .5rem;
        }

        #shop_recommended .aui-grid [class*=aui-col-] {
            padding: .5rem 0
        }

        #shop_recommended .aui-card-list-header,
        #shop_recommended .aui-card-list-footer {
            padding: 0;
        }

        #shop_recommended .aui-info {
            width: 100%;
        }

        #shop_recommended [class*=aui-col-xs-]:nth-child(odd) {
            padding-right: .6rem;
        }

        #shop_recommended [class*=aui-col-xs-]:nth-child(even) {
            padding-left: .6rem;
        }

        #shop_recommended .aui-card-list {
            margin-bottom: 1rem;
        }

        #shop_recommended .title {
            text-align: center;
            margin-bottom: .75rem;
            color: #0689FB;
            display: flex;
            justify-content: center;
            align-items: center;
        }

        #shop_recommended .title img {
            width: 1.4rem;
        }

        #shop_recommended .title span {
            padding-left: .3rem;
            font-size: .9rem;
        }
    </style>
</head>

<body>
    <div id="app">
        <!-- 购物车图标 -->
        <div id="shopping_cart" @click="openWin('shopping_cart')">
            <img src="../../../image/icon/gouwuche.png" alt="">
            <div>购物车</div>
        </div>
        <div class="aui-content">
            <!-- 轮播 -->
            <div id="aui-slide">
                <div class="aui-slide-wrap">
                    <div class="aui-slide-node bg-dark" v-for="data in banner"><img :src="data.pic" alt=""></div>
                </div>
                <div class="aui-slide-page-wrap">
                    <!--分页容器-->
                </div>
            </div>
            <!-- 宫格图标 -->
            <section class="aui-grid">
                <div class="aui-row">
                    <div class="aui-col-xs-3" @click="openWin('commodity_list', {shop_id: api.pageParam.shop_id, cid: data.id, name: data.name})" v-for="data in category">
                        <img :src="data.pic" class="iconimg" :alt="data.name">
                        <div class="aui-grid-label">{{data.name}}</div>
                    </div>
                </div>
            </section>
            <!-- 店家推荐 -->
            <section class="aui-content-padded" id="shop_recommended">
                <div class="title">
                    <div><img src="../../../image/icon/tuijian.png" alt=""></div><span>店铺推荐</span>
                </div>
                <div class="aui-row-padded">
                    <div class="aui-col-xs-6" @click="openWin('commodity_details', {id: data.id, mid: api.pageParam.shop_id})" v-for="data in recommend">
                        <div class="aui-card-list">
                            <div class="aui-card-list-content">
                                <img :src="data.pic" />
                            </div>
                            <div class="aui-card-list-header aui-ellipsis-2">
                                {{data.name}}
                            </div>
                            <div class="aui-card-list-footer">
                                <div class="aui-info">
                                    <div class="aui-info-item aui-text-danger aui-font-size-18">
                                        ￥{{data.price}}
                                    </div>
                                    <div class="aui-info-item">{{data.buy}}人付款</div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </section>
        </div>
    </div>
</body>
<script src="../../../script/api.js" charset="utf-8"></script>
<script src="../../../script/common/jquery-3.3.1.min.js" charset="utf-8"></script>
<script src="../../../script/common/common.js" charset="utf-8"></script>
<script src="../../../script/common/config.js" charset="utf-8"></script>
<script src="../../../script/common/vue.min.js" charset="utf-8"></script>
<script src="../../../script/aui/aui-slide.js" charset="utf-8"></script>
<script>
    apiready = function() {
        api.parseTapmode();

        vm.init();
    }
    var vm = new Vue({
        el: "#app",
        data: {
            banner: [],
            category: [],
            recommend: []
        },
        methods: {
            init() {
                this.getBannerData();
                this.getCategoryData();
                this.getRecommendData();
            },
            getBannerData() {
                var self = this;
                _ajax(Config.api.MallMcharts, {
                    mid: api.pageParam.shop_id
                }, function(res) {
                    if (res.code === 200) {
                        self.banner = res.data;

                        setTimeout(function() {
                            //幻灯特效
                            var slide = new auiSlide({
                                container: document.getElementById("aui-slide"),
                                "height": 240,
                                "speed": 500,
                                "autoPlay": 3000, //自动播放
                                "loop": true,
                                "pageShow": true,
                                "pageStyle": 'dot',
                                'dotPosition': 'center'
                            });
                        }, 200)
                    }
                });
            },
            getCategoryData() {
                var self = this;
                _ajax(Config.api.MallIndex, {
                    mid: api.pageParam.shop_id
                }, function(res) {
                    if (res.code === 200) {
                        self.category = res.data;
                    }
                });
            },
            getRecommendData() {
                var self = this;
                _ajax(Config.api.MallTgoods, {
                    mid: api.pageParam.shop_id
                }, function(res) {
                    if (res.code === 200) {
                        self.recommend = res.data;
                    }
                });
            },
            openWin(name, param = {}) {
                var winInfo = {
                    commodity_list: {
                        name: 'commodity_list_win',
                        url: './commodity_list_win.html',
                        param: param
                    },
                    commodity_details: {
                        name: 'commodity_details_win',
                        url: './commodity_details_win.html',
                        param: param
                    },
                    shopping_cart: {
                        name: 'shopping_cart_win',
                        url: './shopping_cart_win.html',
                        param: param
                    }
                };
                open_w(winInfo[name].name, winInfo[name].url, winInfo[name].param);
            }
        }
    });
</script>

</html>
